// var o;
// exports.WelfareConfig = void 0;
// var s = (function (e) {
//     function t() {
//         return (null !== e && e.apply(this, arguments)) || this;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return this.instance || (this.instance = new t());
//     };
//     t.prototype.destroy = function () {
//         t.instance = null;
//     };
//     t.prototype.jiazai_peizhi = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             var e;
//             var t;
//             var n;
//             var o;
//             var i;
//             var r;
//             var s;
//             var c;
//             var l;
//             return __generator(this, function (a) {
//                 switch (a.label) {
//                     case 0:
//                         return [4, this.yibu_jiazai_txt_peizhi("Welfare")];
//                     case 1:
//                         if ((e = a.sent())) {
//                             this.welfareConf = {};
//                             t = 0;
//                             for (n = e; t < n.length; t++) {
//                                 o = n[t];
//                                 i = o.rewardType;
//                                 r = [];
//                                 for (s = 0; s < i.length; s += 2) {
//                                     c = i[s];
//                                     l = i[s + 1];
//                                     r.push({
//                                         goodsId: c,
//                                         num: l
//                                     });
//                                 }
//                                 o.rewardType = r;
//                                 this.welfareConf[o.id] = o;
//                             }
//                         }
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.huoqu_fuli_peizhi_genju_id = function (e) {
//         return this.welfareConf[e];
//     };
//     t.instance = null;
//     return t;
// })(require("./AL_GAME_HUA_ConfigHandler").ConfigHandler);
// exports.WelfareConfig = s;


// WelfareConfig类用于处理利益相关的配置
exports.WelfareConfig = void 0;

// 使用立即执行函数和闭包创建单例模式
const WelfareConfig = (function (ConfigHandler) {
    class WelfareManager extends ConfigHandler {
        constructor() {
            super();
            this.welfareConf = {}; // 存储福利配置
        }

        /**
         * 获取WelfareManager的单例实例
         * @returns {WelfareManager} WelfareManager实例
         */
        static getInstance() {
            return this.instance || (this.instance = new WelfareManager());
        }

        /**
         * 销毁WelfareManager的实例
         */
        destroy() {
            WelfareManager.instance = null;
        }

        /**
         * 加载配置文件
         */
        async jiazai_peizhi() {
            // 使用ES6解构赋值和Promise语法优化异步等待
            try {
                const welfareData = await this.yibu_jiazai_txt_peizhi("Welfare");
                
                if (welfareData) {
                    // 使用for..of代替for循环，使代码更简洁
                    for (const configItem of welfareData) {
                        const { rewardType: rawRewardType } = configItem;
                        const processedRewards = [];

                        // 使用forEach函数和解构赋值处理配置数据
                        rawRewardType.forEach((value, index) => {
                            if (index % 2 === 0) {
                                const goodsId = value;
                                const num = rawRewardType[index + 1];
                                processedRewards.push({ goodsId, num });
                            }
                        });

                        configItem.rewardType = processedRewards;
                        this.welfareConf[configItem.id] = configItem;
                    }
                }
            } catch (error) {
                console.error("Failed to load config:", error);
            }
        }

        /**
         * 根据ID获取福利配置
         * @param {string | number} id 配置ID
         * @returns {object} 福利配置
         */
        huoqu_fuli_peizhi_genju_id(id) {
            return this.welfareConf[id];
        }
    }

    WelfareManager.instance = null;
    return WelfareManager;
})(require("./AL_GAME_HUA_ConfigHandler").ConfigHandler);

exports.WelfareConfig = WelfareConfig;